<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>


<!-- 
  1.插槽的基本使用: 组件里面定义 <slot></slot>
  2.插槽的默认值:<slot> button....</slot>
  3.如果有多个值,同时放入到组件进行替换时,它会一起作为替换元素

  
 -->

<body>
  <div id="app">
    <cpn><button>按钮2</button></cpn>
    <cpn><span>哇哦</span></cpn>
    <cpn>
      <i>我111</i>
      <div>我222</div>
      <p>我3333</p>
    </cpn>

    <cpn></cpn>
    <cpn></cpn>
    <cpn></cpn>
    <cpn></cpn>
  </div>


  <template id="cpn">
    <div>
      <h2>我是组件</h2>
      <p>我是组件哈哈哈</p>
      <!-- 插槽里面可以给个默认值,如果别人没有传值,这里会显示插槽里面的默认值 -->
      <slot>
        <button>按钮</button>
      </slot>
      <!-- <button>按钮</button> -->
    </div>
  </template>

  <script>
    var vm = new Vue({
      el: '#app',
      data: {},
      methods: {},
      components: {
        cpn: {
          template: '#cpn'
        }
      }
    });
  </script>
</body>

</html>